package com.lgy.httpmocktool.service;

import org.springframework.data.jpa.repository.Modifying;
import org.springframework.stereotype.Service;

import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.Query;
import javax.transaction.Transactional;

@Service
public class SqlExecuteService {
    @PersistenceContext
    private EntityManager entityManager;
    @Transactional
    @Modifying
    public void executeSql(String sql) {
        Query query = entityManager.createNativeQuery(sql);
        query.executeUpdate();
    }
}
